import 'package:opene/ui/b2ctrailer/b2ctrailermodel.dart';

class B2BTrailer {
  String jobId;
  String refId;
  String accountId;
  bool isPalletTag; //是否托盘标 true是 false否

  B2BTrailer({
    this.jobId,
    this.refId,
    this.accountId,
    this.isPalletTag,
  });

  factory B2BTrailer.fromJson(Map<String, dynamic> json) {
    return B2BTrailer(
      jobId: json["jobId"],
      refId: json["refId"],
      accountId: json["accountId"],
      isPalletTag: json["isPalletTag"],
    );
  }

  @override
  String toString() {
    return '$jobId($refId)';
  }
}

class B2bTrailerQr {
  String jobId; //车次Id
  String refId; //车次Id
  String trailer; //车牌号
  int type;
  String closeDoor; //closeDoor图片路径
  String seal; //seal图片路径
  String goods; //goods图片路径
  List<String> lpns = new List(); //lpn
  List<String> bols = new List(); //bols图片路径

  List<TrailerOBLPN> pendingLpns = new List(); //查询待绑定的lpn

  B2bTrailerQr({
    this.jobId,
    this.refId,
    this.trailer,
    this.type,
    this.closeDoor,
    this.seal,
    this.goods,
    this.lpns,
    this.bols,
    this.pendingLpns,
  });

  factory B2bTrailerQr.fromJson(Map<String, dynamic> json) {
    return B2bTrailerQr(
      jobId: json["jobId"],
      refId: json["refId"],
      trailer: json["trailer"],
      type: int.parse(json["type"]),
      closeDoor: json["closeDoor"],
      seal: json["seal"],
      goods: json["goods"],
      lpns: json['lpns'] == null ? null : new List<String>.from(json['lpns']) as List<String>,
      bols: json['bols'] == null ? null : new List<String>.from(json['bols']) as List<String>,
      pendingLpns: json['pendingLpns'] == null ? null : (new List<dynamic>.from(json['pendingLpns']).map((userJson) => TrailerOBLPN.fromJson(userJson)).toList()),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      "jobId": this.jobId,
      "refId": this.refId,
      "trailer": this.trailer,
      "type": this.type,
      "closeDoor": this.closeDoor,
      "seal": this.seal,
      "goods": this.goods,
      "lpns": this.lpns,
      "bols": this.bols,
      "pendingLpns": this.pendingLpns,
    };
  }
}

class PalletTagPrint {
  String fileName;
  String fileBase64;

  PalletTagPrint({
    this.fileName,
    this.fileBase64,
  });

  factory PalletTagPrint.fromJson(Map<String, dynamic> json) {
    return PalletTagPrint(
      fileName: json["fileName"],
      fileBase64: json["fileBase64"],
    );
  }

}
